<?php
require_once 'config.php';
$conn=mysql_connect($host,$user,$password);

if(!conn)
{
 $errorse="Sorry Unable to connect with Server!";
 $_SESSION['errorse']=$errorse;
}
else
{
	
	if(!mysql_select_db($db))
	{session_start();

		$errordb="Sorry Unable to connect to database!";
		$_SESSION['errordb']=$errordb;
	}

}
function authanti($username,$password)
{

	$queryres=mysql_query("SELECT * FROM user WHERE Login_Username='$username' AND Password='$password'");

	if(mysql_num_rows($queryres)==0)
	{
		$errorna="Sorry you are not allowed!";
		$_SESSION['errorna']=$errorna;
	}
	elseif(mysql_num_rows($queryres)==1)
	{
		return true;
		/*while($row=mysql_fetch_array($queryres))
  {
  
	$_SESSION['First_Name']=$row['First_Name'];
	$_SESSION['Last_Name']=$row['Last_Name'];
	
	}*/
	mysql_free_result($queryres);
	}
	else
	{ $_SESSION['errorna']="Sorry you are not allowed!";
		mysql_free_result($queryres);
	
		return false;
	
	}
}

function loggedin()
{
	if($_SESSION['username']!=" " && $_SESSION['password']!=" ")
	{
	
		if(authanti($_SESSION['username'],$_SESSION['password']))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
}
?>